import requests


class IhrmEmpApi:
    @classmethod
    def add_emp_api(cls, token, body):
        url = "http://ihrm2-test.itheima.net/api/sys/user"
        header = {"Content-Type": "application/json", "Authorization": token}       # body = {"username": "小猪佩奇","mobile": "15912312145","workNumber": "22"}
        resp = requests.post(url=url, headers=header, json=body)
        return  resp
    @classmethod
    def query_emp_api(cls, emp_id, token):
        url = "http://ihrm2-test.itheima.net/api/sys/user/"+emp_id
        header = {"Authorization": token}
        resp = requests.get(url=url, headers=header)
        return  resp
    @classmethod
    def modify_emp_api(cls, emp_id, token, body):
        url = "http://ihrm2-test.itheima.net/api/sys/user/"+emp_id
        header = {"Content-Type": "application/json",
                             "Authorization": token }        # body = {"username": "齐天大圣"}
        resp = requests.put(url=url, headers=header, json=body)
        return resp
    @classmethod
    def delete_emp_api(cls, emp_id, token):
        url = " http://ihrm2-test.itheima.net/api/sys/user/"+emp_id
        header = {"Authorization": token}
        resp = requests.delete(url=url, headers=header)
        return resp
